#include"../../include/transformation/rotation.hpp"


namespace transformation{

    float degreeToRadian(float degree){
        return degree * M_PI / 180;
    }
    Matrix44 Rotation::RotateX(float angle) {
        float res[16]{
            1.0f, 0.0f, 0.0f, 0.0f,
            0.0f, std::cos(degreeToRadian(angle)), -std::sin(degreeToRadian(angle)), 0.0f,
            0.0f, std::sin(degreeToRadian(angle)), std::cos(degreeToRadian(angle)), 0.0f,
            0.0f, 0.0f, 0.0f, 1.0f
        };
        return Matrix44(res);
    }
    Matrix44 Rotation::RotateY(float angle) {
        float res[16]{
            std::cos(degreeToRadian(angle)), 0.0f, std::sin(degreeToRadian(angle)), 0.0f,
            0.0f, 1.0f, 0.0f, 0.0f,
            -std::sin(degreeToRadian(angle)), 0.0f, std::cos(degreeToRadian(angle)), 0.0f,
            0.0f, 0.0f, 0.0f, 1.0f
        };
        return Matrix44(res);
    }
    Matrix44 Rotation::RotateZ(float angle) {
        float res[16]{
            std::cos(degreeToRadian(angle)), -std::sin(degreeToRadian(angle)), 0.0f, 0.0f,
            std::sin(degreeToRadian(angle)), std::cos(degreeToRadian(angle)), 0.0f, 0.0f,
            0.0f, 0.0f, 1.0f, 0.0f,
            0.0f, 0.0f, 0.0f, 1.0f
        };
        return Matrix44(res);
    }
    Matrix44 Rotation::Rotate(float x,float y,float z) {
        Matrix44 res = RotateX(x) * RotateY(y) * RotateZ(z);
        return res;
    }
}